package stream;

import lambda.Employee;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author shentianyu
 * @date 2021-06-17 22:41
 * <p>
 * 有终止操作才能执行中间操作
 */
public class StreamAPI2 {
    public static void main(String[] args) {

        List<Employee> employees = Arrays.asList(new Employee("张三", 35, 3000.0), new Employee("李四", 34, 3000.0),
            new Employee("王五", 25, 3000.0), new Employee("赵六", 37, 3000.0), new Employee("田七", 34, 3000.0));

        //内部迭代：由Stream API完成
        employees.stream().filter((e) -> {
            System.out.println("Hello");
            return e.getAge() >= 35;
        }).collect(Collectors.toList()).forEach(System.out::println);

        employees.stream().map(Employee::getName).forEach(System.out::println);

    }
}
